package com.haitaoit.chengquan.module.center.adapter.order;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.haitaoit.chengquan.R;
import com.haitaoit.chengquan.base.BackCall;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.List;

/**
 * Created by Administrator on 2016/10/14.
 */
public class TransportstateAdapter extends BaseAdapter {
    private Context context;
    private List<?> list;
    private BackCall backCall;
    private int checked;

    public void setChecked(int checked) {
        this.checked = checked;
    }

    public void setBackCall(BackCall backCall) {
        this.backCall = backCall;
    }

    public TransportstateAdapter(Context context) {
        this.context = context;
    }

    public List<?> getList() {
        return list;
    }

    public void setList(List<?> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
//        return list == null ? 0 : list.size();
        return 7;
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, final ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.transport_state_item, null);
            holder = new ViewHolder();
            ViewUtils.inject(holder, convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        if (position == 0) {
            holder.tra_line_top.setVisibility(View.INVISIBLE);
            holder.iv_transport_state.setImageResource(R.mipmap.img46);
            holder.transport_state_info.setTextColor(context.getResources().getColor(R.color.qing));
        } else {
            holder.tra_line_top.setVisibility(View.VISIBLE);
            holder.iv_transport_state.setImageResource(R.mipmap.img47);
            holder.transport_state_info.setTextColor(context.getResources().getColor(R.color.text_gray2));
        }

//        if (position == list.size()) {
//            holder.tra_line_bottom.setVisibility(View.INVISIBLE);
//        } else {
//            holder.tra_line_bottom.setVisibility(View.VISIBLE);
//        }

        return convertView;
    }

    class ViewHolder {
        @ViewInject(R.id.tra_line_top)
        View tra_line_top;
        @ViewInject(R.id.tra_line_bottom)
        View tra_line_bottom;
        @ViewInject(R.id.iv_transport_state)
        ImageView iv_transport_state;
        @ViewInject(R.id.transport_state_info)
        TextView transport_state_info;
    }
}
